package com.yugong;

import cn.hutool.extra.pinyin.PinyinUtil;
import com.github.javafaker.Faker;
import com.yugong.mapper.*;
import com.yugong.util.OfficeUtils;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;


@SpringBootTest
class SpringbootApplicationTests {
    @Resource
    private OfficeUtils officeUtils;
    @Resource
    private OrderClassMapper orderClassMapper;
    @Resource
    private CourseArrangeMapper courseArrangeMapper;
    @Resource
    private CourseScoreMapper courseScoreMapper;
    @Resource
    private CourseMapper courseMapper;
    @Resource
    private StudentMapper studentMapper;

    @Test
    void test() {
        Faker faker = new Faker(new Locale("zh", "CN")); // 设置语言为简体中文
        List<String> stringList = new ArrayList<>();
        stringList.add("密码");
        stringList.add("姓名");
        stringList.add("年龄");
        stringList.add("性别");
        stringList.add("学院");
        stringList.add("办公室");
        stringList.add("头像");
        stringList.add("手机号码");
        stringList.add("电子邮箱");

        List<Object> objectList = new ArrayList<>();
        for (int i = 0; i < 6; i++) {
            String name = faker.name().fullName();
            String username = PinyinUtil.getPinyin(name);
            String str = faker.internet().emailAddress(username);
            String email = str.replace(" ", "");
            String phone = faker.phoneNumber().cellPhone();
            Integer age = faker.number().numberBetween(20, 25);
            int sexNumber = faker.number().numberBetween(0, 2);
            String sex = null;
            String avatar = "https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png";
            String password = "123456";
            if (1 == sexNumber) {
                sex = "男";
            } else {
                sex = "女";
            }
            int officeN = faker.number().numberBetween(0, 3);
            String office = "";
            if (1 == officeN) {
                office = "7114-专业教师办公室";
            } else if (2 == officeN) {
                office = "7214-专业教师办公室";
            } else {
                office = "7314-专业教师办公室";
            }
            objectList.add(password);
            objectList.add(name);
            objectList.add(age);
            objectList.add(sex);
            objectList.add("管理学院");
            objectList.add(office);
            objectList.add(avatar);
            objectList.add(phone);
            objectList.add(email);
        }
        boolean flag = officeUtils.exportExcel("", "订单班管理员", "", stringList, objectList);
        System.out.println(flag);
    }

    @Test
    void testStudent() {
    }
}
